package com.example.tool.activtiy.recylerview;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.example.tool.R;
import com.example.tool.activtiy.base.BaseActivity;
import com.example.tool.adapter.ShowAdapter;
import com.example.tool.adapter.base.CommonAdapter;
import com.example.tool.adapter.base.CommonViewHolder;
import com.example.tool.mvp.CommonPresent;
import com.example.tool.util.DebugLog;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import butterknife.BindView;

/**
 * Created Date 2019/8/25.
 *
 * @author liangkun
 * ClassDescription：
 */
public class AdapterActivtiy extends BaseActivity<CommonPresent> {
    @BindView(R.id.rv_home)
    protected RecyclerView recyclerView;
    @BindView(R.id.tv_title)
    protected TextView tvTitle;
    private List<String> mDatas = new ArrayList<>(Arrays.asList("普通封装的RecyclerView", "BaseAdapterHelper(单条目)",
            "BaseAdapterHelper(多条目)", "BaseAdapterHelper(伸缩)","BaseAdapterHelper(网格)"));
    private ShowAdapter showAdapter;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_adapter;
    }

    @Override
    protected void initView() {
        tvTitle.setText(R.string.base_adapter);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
        recyclerView.setLayoutManager(layoutManager);
        DebugLog.d(DebugLog.KUN + "mDatas " + mDatas.size());
        showAdapter = new ShowAdapter(this, mDatas, R.layout.home_list);

    }

    @Override
    protected void initData() {
        recyclerView.setAdapter(showAdapter);
        DebugLog.d(DebugLog.KUN + "initData ");
        showAdapter.setOnItemClickListener(new CommonAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View view, CommonViewHolder holder, int position) {
                switch (position) {
                    case 0:
                        startToActivity(AdapterActivtiy.this, RecylerViewActivity.class);
                        break;
                    case 1:
                        startToActivity(AdapterActivtiy.this, SingleItemRvActivity.class);
                        break;
                    case 2:
                        startToActivity(AdapterActivtiy.this, MultiItemRvActivity.class);
                        break;
                    case 3:
                        startToActivity(AdapterActivtiy.this, ExpandItemRvActivity.class);
                        break;
                    case 4:
                        startToActivity(AdapterActivtiy.this, GrideRvActivity.class);
                        break;
                }
            }

            @Override
            public boolean onItemLongClick(View view, CommonViewHolder holder, int position) {
                return false;
            }
        });
    }

    @Override
    protected void initEvent() {

    }

    @Override
    protected CommonPresent createPresenter() {
        return null;
    }
}
